package com.study.base.io;

import java.io.File;
import java.io.IOException;

/**
 * @description: FileTest3 输出盘符下所有的文件夹路径
 * @date: 2021/1/14 13:00
 * @author: hcm
 * @version: 1.0
 */
public class FileTest4 {
    public static void main(String[] args) {
        FileTest4.showFile("D:\\");

    }

    public static void showFile(String pathName) {

        File file = new File(pathName);
        //判断文件是否是文件夹
        boolean directoryFlag = file.isDirectory();
        if (directoryFlag) {
            //选择某个文件夹下所有的文件
            File[] files = file.listFiles();
            //递归删除
            for (int i = 0; files != null && i < files.length; i++) {
                    boolean directoryFlag2 = files[i].isDirectory();
                if (directoryFlag2) {
                    showFile(files[i].getPath());
                } else {
                    String path = file.getPath();
                    System.out.println("普通文件--------》" + path);
                }
            }
        } else {
            String path = file.getPath();
            System.out.println("普通文件--------》" + path);
        }


    }
}
